-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OTEL wiring in grpcserver interceptor (DataDog POC) #612
Conversation
WalkthroughThe recent updates introduce OpenTelemetry tracing into the gRPC server functionality within the codebase. This enhancement includes importing necessary OpenTelemetry libraries and incorporating tracing logic into the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant gRPCServer
participant OpenTelemetry
Client->>gRPCServer: Send gRPC request
gRPCServer->>OpenTelemetry: Start trace
gRPCServer->>gRPCServer: Process request
gRPCServer->>OpenTelemetry: End trace
gRPCServer->>Client: Send response
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
return handler(grpcCtx, req) | ||
// Extract the existing span context from the incoming request | ||
parentCtx := otel.GetTextMapPropagator().Extract(grpcCtx, propagation.HeaderCarrier(md)) | ||
|
||
// Start a new span representing the request | ||
// The span ends when the request is complete | ||
grpcCtx, span := tracer.Start(parentCtx, grpcInfo.FullMethod, trace.WithSpanKind(trace.SpanKindServer)) | ||
defer span.End() | ||
|
||
span.SetAttributes(attribute.String("http.method", grpcInfo.FullMethod)) | ||
|
||
resp, err = handler(grpcCtx, req) | ||
|
||
if err != nil { | ||
span.SetStatus(otelcodes.Error, err.Error()) | ||
} else { | ||
span.SetStatus(otelcodes.Ok, "OK") | ||
} | ||
|
||
return resp, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link
version: v1.51.2 | ||
version: v1.54.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to do this because this is the first version that supports go 1.21
@@ -8,7 +8,6 @@ run: | |||
linters: | |||
disable-all: true | |||
enable: | |||
- depguard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: too many complaints after linter version bump so I removed it
* OTEL wiring in grpcserver * updates * updates * grpc headers * updates * updates * updates * go 1.21 * updates * test go1.21 * update lint go * go mod for tests * more updates * bump linter version * updates * remove nakedret * codeql go version
) (#619) * OTEL wiring in grpcserver interceptor (DataDog POC) (backport #612) * updates * deps * updates * updates * updates * updates * lint --------- Co-authored-by: Roman <[email protected]>
This PR wires up OTEL tracing in gprcserver interceptor, allowing tracing requests that originate from external services.
I had to bump up go as 1.20 did not support some of the otel grpc dependencies.
This has led to bumping up go versions of a lot of the CI stuff.
Tested.